package service.impl;

import mapper.BlogMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import pojo.Blog;
import service.BlogService;


import javax.annotation.Resource;
import java.util.List;
@Service("blogService")
public class BlogServiceImpl implements BlogService {
    @Resource
    private BlogMapper blogMapper;


    //单个Blog详细
    @Override
    public Blog getBlogById(int blogid) {
        return null;
    }

    //添加Blog
    @Override
    public int insert(Blog blog) {
        return blogMapper.insert(blog);
    }

    @Override
    public int delete(String blogid) {
        return blogMapper.deletemypublish(blogid);
    }

    @Override
    public List<Blog> getBlogPager(@Param("region") String region,
                                   @Param("pageNo") int pageNO,
                                   @Param("size") int size) {
        int start = (pageNO-1)*size;  //从第几条开始查，查几条
        return blogMapper.getBlogPager(region,start, 5);
    }

    @Override
    public int getBlogCount() {
        return blogMapper.getBlogCount();
    }

    @Override
    public int getBlogCountByuserid(String userid) {
        return blogMapper.getBlogCountByuserid(userid);
    }


    public List<Blog> getBlogByUserId(String userid) {
        return blogMapper.getBlogByUserId(userid);
    }



    @Override
    public List<Blog> selectHomeBlog( String types) {
        return blogMapper.selectHomeBlog(types);
    }

    @Override
    public List<Blog> selecVague(@Param("content") String content,
                                 @Param("type")String type) {
        return blogMapper.selecVague(content, type);
    }

    @Override
    public Blog selectById(String blogid) {
        return blogMapper.selectById(blogid);
    }

    @Override
    public int audit(String blogid, String status) {
        return blogMapper.audit(blogid,status);
    }

    @Override
    public List<Blog> getBlogalljson() {
        return blogMapper.getBlogalljson();
    }


    @Override
    public List<Blog> selectdetailBlog(String blogId) {

        return blogMapper.selectdetailBlog(blogId);
    }

    @Override
    public List<Blog> selectBlog() {
        return blogMapper.selectBlog();
    }



    public List<Blog> selectPersonBlog(@Param("userid") String userid,
                                     @Param("pageNo") int pageNO,
                                     @Param("size") int size) {
        return blogMapper.selectPersonBlog(userid,pageNO, 5);
    }


}
